<?php
$db = new SQLite3("students.db");
$data = json_decode($_POST["ajax"], true);
if ($data["items_index"] == 0) {
    $res = $db->query("select * from students where id='".$data["input_msg"]."'");
} else {
    $res = $db->query("select * from students where name='".$data["input_msg"]."'");
}
if ($res) {
    $arr = $res->fetchArray(SQLITE3_ASSOC);
    echo json_encode($arr);
} else {
    echo json_encode(array(array('id'=>'null', 'name'=>'null', 'mclass'=>"null")));
}
?>